<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
require_once "java/lang/Character.php";
/**
 * Description of YaziIsleyici
 *
 * @author Sedat Sevgili
 */
class YaziIsleyici {
    //put your code here
    
    protected static $_wordDelimiters = array(
        ' ', '\t', '\n', '\r', '.', ',', ':', ';', '!', '"', '<', '>', '£', '#', '$', '%', '&', '/', '(', ')', '=', '?', '-', '_', '½', '{', '[', ']', '}', '\\', '|'
    );
    
    protected static $_sentenceDelimiters = array(
        '.', '!', '?', ':'
    );
    
    /**
     * Verilen metni kelimelerine ayırır. Noktalama işaretleri filtrelenir.
     * @param string $target
     * @return array 
     */
    public static function kelimeAyikla($target) {
        $target = str_replace(self::$_wordDelimiters, ' ', $target);
        return explode(' ', $target);
    }
    
    public static function analizIcinKelimeAyikla($target) {
        $cumleler = self::cumleAyikla($target);
        $tumKelimeler = array();
        //for($i = 0; $i < count($cumleler); $i++) {
        foreach($cumleler as $cumle) {
            $kelimeler = self::kelimeAyikla($cumle);
            //for($j = 0; $j < count($kelimeler); $j++) {
            foreach($kelimeler as $kelime) {
                if(Character::isLowerCase($kelime[0])) {
                    if(strpos(".", $kelime) === false && strpos("-", $kelime) === false) {
                        $tumKelimeler[] = $kelime;
                    }
                }
            }
        }
        return $tumKelimeler;
    }
    
    public static function cumleAyikla($target) {
        $target = str_replace(self::$_sentenceDelimiters, ' ', $target);
        return explode(' ', $target);
    }
    
    /**
     * Verilen metnin içinde geçen kelimeler listesini döndürür. Hö?
     * @param string $target 
     * @return array
     */
    public static function analizDizisiOlustur($target) {
        $yaziBirimleri = array();
        $kelimeler = self::kelimeAyikla($target);
        foreach($kelimeler as $kelime) {
            
        }
    }
    
}